<template>
    <!-- 这是新闻资讯列表 -->
    <div>
        <ul class="mui-table-view">
			<li class="mui-table-view-cell mui-media" v-for="item in newslist" :key="item.id">
                <!-- 将a连接改为router-link标签 -->
                <router-link :to="'/home/newsinfo/'+item.id">
					<img class="mui-media-object mui-pull-left" 
                    :src="item.img_url">
					<div class="mui-media-body">
						<h3>{{item.title}}</h3>
						<p class='mui-ellipsis'>
                           <span>发表时间：{{item.add_time | dateFormat}}</span> 
                           <span>点击：{{ item.click }}次</span>
                        </p>
					</div>
				</router-link>
			</li>
			<!-- <li class="mui-table-view-cell mui-media">
				<a href="javascript:;">
					<img class="mui-media-object mui-pull-left"
                     src="../../images/03.jpg">
					<div class="mui-media-body">
						<h3>幸福</h3>
						<p class='mui-ellipsis'>
                           <span>发表时间：2019-11-11 11:11:11</span> 
                           <span>点击：0次</span>
                        </p>
					</div>
				</a>
			</li>
			<li class="mui-table-view-cell mui-media">
				<a href="javascript:;">
					<img class="mui-media-object mui-pull-left" 
                    src="../../images/01.jpg">
					<div class="mui-media-body">
						<h3>幸福</h3>
						<p class='mui-ellipsis'>
                           <span>发表时间：2019-11-11 11:11:11</span> 
                           <span>点击：0次</span>
                        </p>
					</div>
				</a>
			</li> -->
		</ul>
        <!-- <h3>这是新闻资讯列表</h3> -->
    </div>
</template>

<script>
// 8-12.1 发送请求，获取图文资讯
import { Toast } from "mint-ui"

export default {
    data(){
        return {
            newslist:[] //新闻列表
        };
    },  
    created(){
      this.getNewsList();
    },
    methods:{
        // 发起图文资讯的请求
       getNewsList(){
           this.$http.get('api/getnewslist').then(res=>{
               if(res.body.status===0){
                   console.log("请求成功")
                //    console.log(res.body)
                this.newslist=res.body.message;
               }else {
                   console.log("失败")
               }
           })
       }
    }
}
</script>

<style lang="scss" scoped>
    .mui-table-view{
        li {
            h3{
                font-size: 20px;
            }
           .mui-ellipsis{
               font-size: 14px;
               color: #226aff;
            //    让span中的内容左右显示
              display: flex;
                justify-content: space-between;
           } 
        }
    }

</style>
